
from whiff.middleware import misc

class __middleware__(misc.utility):
    def __init__(self, page):
        self.page = page
    def __call__(self, env, start_response):
        content_length_str = env.get("CONTENT_LENGTH")
        if content_length_str:
            content_length = int(content_length_str)
            inpt = env.get("wsgi.input")
            if inpt:
                postdata = inpt.read(content_length)
                f = file("/tmp/post.txt", "wb")
                f.write(postdata)
                f.close()
        return self.deliver_page(self.page, env, start_response)
